#ifdef SUPPORT_MS_EXTENSIONS
#pragma bss_seg(".icsd_anc.data.bss")
#pragma data_seg(".icsd_anc.data")
#pragma const_seg(".icsd_anc.text.const")
#pragma code_seg(".icsd_anc.text")
#endif

#include "app_config.h"
#include "audio_config_def.h"
#if (TCFG_AUDIO_ANC_EAR_ADAPTIVE_EN && \
	 TCFG_AUDIO_ANC_ENABLE && \
	 TCFG_AUDIO_ANC_EAR_ADAPTIVE_VERSION == ANC_EXT_V1)

#include "audio_anc.h"

const u8 ICSD_ANC_TOOL_DEBUG = 1;

const float jt_thd_1 = 3;
const float jt_thd_2 = 5;
const float THD_JT = 6;
const float THD_JT_SAVE = 4;
const float THD_JT2 = 7;

const s8 ANC_s8_DATA[] = {
    6,//P_PARAM_01
    -12,//P_PARAM_02
    4,//SP_PARAM_01
    -12,//SP_PARAM_01
    28,//ANC_ERRMIC_SPL_DB
    12,//ANC_SZ_DB
    -10,//EAR_CHECK_VLD1
    -9,//EAR_CHECK_VLD2
    40,//FSTOP_IDX
    58,//FSTOP_IDX2
    41,//_ANC_REFMIC_SPL_DB
    -4,//B_PARM1_THR_L
    4,//B_PARM1_THR_H
    -6,//B_PARM2_THR_L
    6,//B_PARM2_THR_H
    -4,//B_PARM3_THR_L
    4,//B_PARM3_THR_H
};

const double ICSD_ANC_DOUBLE_DATA[] = {
//double cmp_iir_ab[10] //
    1.000496069900691509246826171875, -1.998426330275833606719970703125, 0.997930623590946197509765625, -1.998426330275833606719970703125, 0.9984266944229602813720703125,
    0.9998088735155761241912841796875, -1.999607323668897151947021484375, 0.9997985516674816608428955078125, -1.999607323668897151947021484375, 0.9996074251830577850341796875,
};

const float spl_tb [21] = {
    17, //134.765625000000
    19, //179.687500000000
    21, //224.609375000000
    22, //269.531250000000
    23, //314.453125000000
    23, //359.375000000000
    24, //404.296875000000
    26, //449.218750000000
    23, //494.140625000000
    24, //539.062500000000
    25, //583.984375000000
    25, //628.906250000000
    24, //673.828125000000
    22, //718.750000000000
    22, //763.671875000000
    23, //808.593750000000
    24, //853.515625000000
    25, //898.437500000000
    25, //943.359375000000
    24, //988.281250000000
    24, //1033.20312500000
};

const float spl_freq_tb [21] = {
    134.765625000000,
    179.687500000000,
    224.609375000000,
    269.531250000000,
    314.453125000000,
    359.375000000000,
    404.296875000000,
    449.218750000000,
    494.140625000000,
    539.062500000000,
    583.984375000000,
    628.906250000000,
    673.828125000000,
    718.750000000000,
    763.671875000000,
    808.593750000000,
    853.515625000000,
    898.437500000000,
    943.359375000000,
    988.281250000000,
    1033.20312500000
};

const float ICSD_ANC_DATA[] = {
//float ff_fgq[25]
    1,//gain
    10000, 20.000, 1.000, //F G Q
    1200, -3.500, 1.000,
    2000, -4.000, 1.000,
    6500, -6.000, 1.000,
    10000, -30.000, 1.500,
    75, 2.000, 2.000,
    385, -4.260, 0.505,
    620, 1.600, 1.500,
//float fb_fgq[25]
    0.707945,//gain
    3500.0, -6.000,  0.900,  //F G Q
    1510.0, -2,      0.800,
    5289.0, -11,     0.800,
    120.0, 18.000, 0.600,
    45.0,    3.000, 1.000,
    20.0,    0.0,    1.000,
    20.0,    0.0,    1.000,
    20.0,    0.0,    1.000,
//float ff_weight_HT03[75]
    0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 10.00, 10.00, 10.00,
    10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.00,
    5.100, 5.100, 0.100, 0.100, 0.100, 0.100, 0.100, 0.100, 0.100, 0.100, 0.100, 0.100, 0.100, 0.100, 0.100,
    0.100, 0.100, 0.100, 0.100, 0.100, 0.100, 0.100, 0.100, 0.100, 0.100, 0.100, 0.100, 0.100, 0.100, 0.100,
    0.100, 0.100, 0.100, 0.100, 0.100, 0.100, 0.100, 0.100, 0.100, 0.100, 0.100, 0.100, 0.100, 0.100, 0.100,
//float best_param_fix[13]
    -3.00,
    0.900, -6.000, 3500.0,  // Q G F
    0.800, -2,     1510.0,
    0.800, -11,    5289.0,
    1.000,  0.0,   20.0,
//float	best_param_flex[6]
    0.600, 18.000, 120.0,
    1.000,  3.000, 45.0,
//float biquad_init_lcl[10]
    -1, 150, 0.5,
    -3, 500, 1,
    -7, 1200, 0.8,
    -1,
//float biquad_fix[15]
    8,   60, 1.8,
    -10,  15, 1.5,
    4.5, 4500, 0.8,
    -8,   7500, 2,
    -25, 14000, 1.2,
//float Vrange[26]
    -5.0, 5.0, 130, 400, 0.3, 1,
    -5.0, 5.0, 400, 900, 0.3, 1,
    -10.0, -5.0, 900, 1400, 0.7, 0.9,
    -1.1, -0.9,
    0.0, 0.0, 0.0, 0.0, 0.0, 0.0, //没有使用
//float biquad_init_data[7]
    1.0,//highshlef_N
    4.0,//peak_N
    5.0,//N
    1.0,//h_fix
    2.0,//p_fix
    3.0,//n_fix
    2.0,//n_flex
//float fb_std[3]
    1.414,
    0.707,
    20.0,
//float k_cmp[75*2]
    0.355735, 0.000000,
    0.406650, 0.009267,
    0.540936, 0.013891,
    0.677297, 0.006987,
    0.661146, -0.122581,
    0.762457, -0.082076,
    0.845315, -0.032340,
    0.922015, 0.001376,
    0.983304, 0.017571,
    1.003132, 0.021645,
    1.013473, 0.016530,
    1.014149, 0.007091,
    1.005985, -0.001269,
    0.992157, -0.002376,
    0.982547, 0.008197,
    0.987876, 0.019249,
    0.993822, 0.015540,
    0.984279, 0.010513,
    0.969368, 0.020658,
    0.970804, 0.034582,
    0.996935, 0.025907,
    0.985948, 0.031042,
    0.935211, 0.022464,
    0.953423, 0.025235,
    0.961401, 0.012630,
    0.929649, 0.025147,
    0.916033, 0.070842,
    0.908546, 0.113489,
    0.890224, 0.146915,
    0.880289, 0.170188,
    0.897130, 0.177176,
    0.899322, 0.215329,
    0.902587, 0.219978,
    0.901702, 0.301843,
    0.930309, 0.364164,
    0.958195, 0.421897,
    1.015677, 0.431439,
    1.046609, 0.453263,
    1.089167, 0.435698,
    1.112152, 0.445592,
    1.149376, 0.458663,
    1.143086, 0.467994,
    1.178618, 0.494142,
    1.178230, 0.490062,
    1.202727, 0.519448,
    1.264703, 0.538896,
    1.300802, 0.571430,
    1.309515, 0.629530,
    1.383454, 0.672111,
    1.433505, 0.684519,
    1.510080, 0.676279,
    1.680950, 0.720572,
    1.649127, 0.726221,
    1.787352, 0.769206,
    1.911621, 0.671973,
    1.936819, 0.780815,
    2.111839, 0.570215,
    2.236738, 0.596179,
    2.329324, 0.556353,
    2.423803, 0.479938,
    2.548114, 0.379554,
    2.495549, 0.279278,
    2.675386, -0.007060,
    2.512869, -0.084337,
    2.723908, -0.190948,
    2.353746, -0.626941,
    2.550212, -0.385014,
    2.369031, -0.435515,
    2.333464, -0.795883,
    1.912714, -0.841469,
    1.844244, -1.095402,
    1.741950, -1.333718,
    1.919448, -1.361989,
    1.672145, -1.309203,
    1.559095, -0.326499,
//cmp_fix_biquad
    -31.603,  19,      5,
    4.247,   36,      0.3,
    -12.149,  9046,    0.9,
    11.905,  6464,    1.2,
//cmp_flex_vrange
    -8,   8,    100,   300,  0.6,  1,
    -8,   8,    400,   800,  0.5,  1,
    -8,   8,    800,   1000,  0.5, 1,
    -5,   5,    1000,  1500,  0.8, 1.5,
    0.35481,   0.35481,
//cmp_flex_init
    4.985, 193, 0.8,
    0,    500,   1,
    6.1,  900, 0.57,
    0,  1200, 0.5,
//cmp_weight
    0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 10.00, 10.00, 10.00, 10.00,
    10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.00,
    10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 3.000, 3.000, 3.000,
    0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
    0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
//cmp_iir_ab_idx
    2,
//nmss_config
    1,//flex_seq[0]
    2,//flex_seq[1]
    0,//flex_seq[2]
    0,//flex_seq[3]
    0,//flex_seq[4]
    0,//flex_seq[5]
    2,//n
    1.0,//rho
    2.0,//chi
    0.5,//psi
    0.5,//sigma
    250,//maxnum
    0.10,//usual_delta
    5.0,//zero_term_delta
//lowshelf_config
    0,   //en
    26,  //f
    -8.0,//g
    1.0, //q
};
#endif/*TCFG_AUDIO_ANC_EAR_ADAPTIVE_EN*/
